/***********************************************************************
 * Module:  PERIOD_OBRACUNA.java
 * Author:  Igor Spremo, Milan Stojkov
 * Purpose: Defines the Class PERIOD_OBRACUNA
 ***********************************************************************/

package model.entity;

import java.io.Serializable;
import java.sql.Date;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;

/**
 * 
 * @author Igor Spremo, Milan Stojkov
 *
 */

@SuppressWarnings("serial")
public class PeriodObracuna implements Serializable {
	
	protected Integer id;
	protected Date pocetakPeriodaObracuna;
	protected Date krajPeriodaObracuna;
	protected int verzija;

	protected Collection<Faktura> fakture;

	public Collection<Faktura> getFakture() {
		if (fakture == null)
			fakture = new HashSet<Faktura>();
		
		return fakture;
	}

	public Iterator<Faktura> getIteratorFakture() {
		if (fakture == null)
			fakture = new HashSet<Faktura>();
		
		return fakture.iterator();
	}

	public void setFakture(Collection<Faktura> newFakture) {
		removeAllFakture();
		for (Iterator<Faktura> iter = newFakture.iterator(); iter.hasNext();)
			addFaktura((Faktura) iter.next());
	}

	public void addFaktura(Faktura newFaktura) {
		if (newFaktura == null)
			return;
		if (this.fakture == null)
			this.fakture = new HashSet<Faktura>();
		if (!this.fakture.contains(newFaktura))
			this.fakture.add(newFaktura);
	}

	public void removeFaktura(Faktura oldFaktura) {
		if (oldFaktura == null)
			return;
		if (this.fakture != null)
			if (this.fakture.contains(oldFaktura))
				this.fakture.remove(oldFaktura);
	}

	public void removeAllFakture() {
		if (fakture != null)
			fakture.clear();
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Date getPocetakPeriodaObracuna() {
		return pocetakPeriodaObracuna;
	}

	public void setPocetakPeriodaObracuna(Date pocetakPeriodaObracuna) {
		this.pocetakPeriodaObracuna = pocetakPeriodaObracuna;
	}

	public Date getKrajPeriodaObracuna() {
		return krajPeriodaObracuna;
	}

	public void setKrajPeriodaObracuna(Date krajPeriodaObracuna) {
		this.krajPeriodaObracuna = krajPeriodaObracuna;
	}

	public int getVerzija() {
		return verzija;
	}

	public void setVerzija(int verzija) {
		this.verzija = verzija;
	}

}